﻿using Mes.Domain.BoundedContext.EntityBase;

namespace Mes.Domain.BoundedContext.Entities.WorkOrders
{
    public class Job : NoIdEntityBase
    {
        public Job() { }

        public Job(string woId, string operId, int itemId, double qtyAtStart, double qtyReqd, DateTime? reqFinishTimeLocal, int initSchedEntId, int targetSchedEntId, string? jobDesc = "",
            bool firstJob = false, bool finalJob = false, int displayDeq = 0, double estProdRate = 0, double? estLabRate = 0, double? estSetupTime = 0, double? estTeardownTime = 0,
            double? estTransferTime = 0, double? jobCost = 0, string? notes = "", int jobStateCd = 1, int jobPriority = 50)
        {
            Wo_Id = woId;
            Oper_Id = operId;
            Item_Id = itemId;
            Qty_At_Start = qtyAtStart;
            Qty_Reqd = qtyReqd;
            Req_Finish_Time_Local = reqFinishTimeLocal;
            Init_Sched_Ent_Id = initSchedEntId;
            Target_Sched_Ent_Id = targetSchedEntId;
            Job_Desc = jobDesc;
            First_Job = firstJob;
            Final_Job = finalJob;
            Display_Seq = displayDeq;
            Est_Prod_Rate = estProdRate;
            Est_Lab_Rate = estLabRate;
            Est_Setup_Time = estSetupTime;
            Est_Teardown_Time = estTeardownTime;
            Est_Transfer_Time = estTransferTime;
            Job_Cost = jobCost;
            Notes = notes;
            State_Cd = jobStateCd;
            Job_Priority = jobPriority;
        }

        public string Wo_Id { get; set; } = string.Empty;

        public string Oper_Id { get; set; } = string.Empty;

        public string? Job_Desc { get; set; }

        public int Item_Id { get; set; }

        public int State_Cd { get; set; } = 1;

        public int Job_Priority { get; set; } = 1;

        public DateTime? Req_Finish_Time_Utc { get; set; }

        public DateTime? Req_Finish_Time_Local { get; set; }

        public int Init_Sched_Ent_Id { get; set; }

        public int Target_Sched_Ent_Id { get; set; }

        public int? Run_Ent_Id { get; set; }

        public double Qty_Reqd { get; set; }

        public double Qty_Prod { get; set; }

        public double? Qty_Prod_Erp { get; set; }

        public double Qty_Rejected { get; set; }

        public double? Qty_Rejected_Erp { get; set; }

        public double Qty_At_Start { get; set; }

        public double Deviation_Above { get; set; }

        public double Deviation_Below { get; set; }

        public double Batch_Size { get; set; }

        public int? Uom_Id { get; set; }

        public bool First_Job { get; set; }

        public bool Final_Job { get; set; }

        public bool Sched_Pinned { get; set; }

        public bool Check_Inv { get; set; }

        public double? Est_Fixed_Lab { get; set; }

        public double? Est_Lab_Rate { get; set; }

        public double? Est_Setup_Time { get; set; }

        public double? Est_Teardown_Time { get; set; }

        public double Est_Prod_Rate { get; set; }

        public int Prod_Uom { get; set; }

        public double? Est_Transfer_Time { get; set; }

        public DateTime? Sched_Start_Time_Utc { get; set; }

        public DateTime? Sched_Start_Time_Local { get; set; }

        public DateTime? Latest_Start_Time_Utc { get; set; }

        public DateTime? Latest_Start_Time_Local { get; set; }

        public DateTime? Sched_Finish_Time_Utc { get; set; }

        public DateTime? Sched_Finish_Time_Local { get; set; }

        public DateTime? Act_Start_Time_Utc { get; set; }

        public DateTime? Act_Start_Time_Local { get; set; }

        public DateTime? Act_Finish_Time_Utc { get; set; }

        public DateTime? Act_Finish_Time_Local { get; set; }

        public int Concurrent_Link { get; set; }

        public double? Job_Cost { get; set; }

        public bool Parent_Contingent_Job { get; set; }

        public bool Child_Contingent_Job { get; set; }

        public string? Notes { get; set; }

        public string? Assoc_File { get; set; }

        public string? Assoc_File_Type { get; set; }

        public string? Status_Notes { get; set; }

        public int Display_Seq { get; set; }

        public string? Folder_Ver_Id { get; set; }

        public bool Rework { get; set; }

        public string? Rework_Cd { get; set; }

        public string? Rework_Process_Id { get; set; }

        public string? Spare1 { get; set; }

        public string? Spare2 { get; set; }

        public string? Spare3 { get; set; }

        public string? Spare4 { get; set; }

        public string? Last_Edit_Comment { get; set; }

        public string? Edited_By { get; set; }

        public DateTime Edit_Time { get; set; }

        public int Row_Id { get; set; }
    }
}
